package com.huobao.yunying.activitys;

import android.content.Intent;
import android.view.View;

import com.easemob.easeui.EaseConstant;
import com.huobao.yunying.base.HuobaoBaseActivity;
import com.huobao.yunying.fragments.ChatFragment;
import com.huobao.zhangying.R;

/**
 * Created by Administrator on 2016/9/8.
 */
public class Act_Chat extends HuobaoBaseActivity{
	private ChatFragment chatFragment;
	@Override
	protected int getContentView() {
		return R.layout.em_activity_chat;
	}

	@Override
	protected String getTitleText() {
		return null;
	}

	@Override
	protected void init() {
		mAbTitleBar.setVisibility(View.GONE);
		chatFragment = new ChatFragment();
		Intent intent = getIntent();
		intent.putExtra(EaseConstant.EXTRA_USER_ID, "liyanlong");
		intent.putExtra(EaseConstant.EXTRA_SHOW_USERNICK, true);
		// 传入参数
		chatFragment.setArguments(intent.getExtras());
		getSupportFragmentManager().beginTransaction().add(R.id.container, chatFragment).commit();
	}

	@Override
	protected void onNewIntent(Intent intent) {
		super.onNewIntent(intent);
		setIntent(intent);
		// 点击notification bar进入聊天页面，保证只有一个聊天页面
		String username = intent.getStringExtra("userId");
		if ("shouqian".equals(username))
			super.onNewIntent(intent);
		else {
			finish();
			startActivity(intent);
		}

	}
	@Override
	public void onBackPressed() {
		chatFragment.onBackPressed();
	}
	public void sendRobotMessage(String txtContent, String menuId) {
		chatFragment.sendRobotMessage(txtContent, menuId);
	}


}
